package com.cbank.controller.admin;

import com.cbank.constants.Result;
import com.cbank.constants.ResultCode;
//import com.cbank.utils.QiniuUtils;
import com.cbank.utils.StringUtil;
import com.cbank.utils.UniqueKeyGenerator;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.commons.CommonsMultipartFile;


@Controller
@RequestMapping("/file")
public class FileController {

    @RequestMapping(value = "/upload",method = RequestMethod.POST)
    @ResponseBody
    public Result<String> uploade(@RequestParam(value = "file",required = true) CommonsMultipartFile file){
        String fileName=null;
        try {
//            fileName=QiniuUtils.upload(file.getBytes(), UniqueKeyGenerator.generateUUID());
        }catch (Exception e){
            e.printStackTrace();
            return new Result<String>(ResultCode.ERROR_QINIU.getCode(),ResultCode.SUCCESS.getMsg(), StringUtil.EMPTY_STRING);
        }
        return new Result<String>(ResultCode.SUCCESS.getCode(),ResultCode.SUCCESS.getMsg(),fileName);
    }
}
